//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.周赛.周赛448;

public class Q2 {
    public Q2() {
    }

    public int[][] specialGrid(int N) {
        int size = (int)Math.pow((double)2.0F, (double)N);
        int[][] grid = new int[size][size];
        this.fill(grid, 0, 0, size, 0);
        return grid;
    }

    private void fill(int[][] grid, int x, int y, int L, int start) {
        if (L == 1) {
            grid[x][y] = start;
        } else {
            int half = L / 2;
            int qSize = L * L / 4;
            this.fill(grid, x, y + half, half, start);
            this.fill(grid, x + half, y + half, half, start + qSize);
            this.fill(grid, x + half, y, half, start + 2 * qSize);
            this.fill(grid, x, y, half, start + 3 * qSize);
        }
    }
}
